<template>
    <div class="login">
        <div class="login-context">
            <!--头部图片-->
            <div class="login-logo">
                <img src="../assets/logo.png" alt="">
            </div>
            <!--form表单-->
            <el-form :model="registForm" :rules="loginFormRul" ref="loginFormRef" label-width="100px" class="login-box">
                <el-form-item prop="username">
                    <el-input v-model="registForm.username" placeholder="账号" tabindex="1"></el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" v-model="registForm.password" placeholder="密码" tabindex="2"></el-input>
                </el-form-item>
                <el-form-item prop="idcard">
                    <el-input type="text" v-model="registForm.idcard" placeholder="身份证号码" tabindex="3"></el-input>
                </el-form-item>
                <el-form-item class="login-btn">
                    <el-button type="primary" @click="register" @keyup.enter="keyDown">注册</el-button>
                </el-form-item>
                <el-form-item>
                    <div class="box">
                        <div>
                            <el-icon>
                                <User />
                            </el-icon>
                            去登陆
                        </div>
                    </div>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'YaodaoRegister',

        data() {
            return {
                registForm: {
                    username: '',
                    password: '',
                    idcard: ''
                },
                loginFormRul: {
                    username: [
                        { required: true, message: '请输入用户名', trigger: 'blur' },
                        { min: 3, max: 8, message: '长度在 3 到 8 个字符', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        { min: 3, max: 8, message: '长度在 3 到 8 个字符', trigger: 'blur' }
                    ],
                    idcard:[
                        {required:true ,message:'请输入身份证号',trigger: 'blur' },
                        { min: 18, max: 18, message: '身份证号只能为18位', trigger: 'blur' }
                    ]
                }
            };
        },

        mounted() {

        },

        methods: {
            register(){
                let that = this;
                that.$http.post('',that.registForm)
                .then(function(result){
                    console.log("result",result);
                })
                .catch(function(error){
                    console.log("error",error);
                })
            }
        },
    };
</script>

<style lang="scss" scoped>
    .login {
        height: 100%;
        background-color: black;
    }

    .login-context {
        width: 450px;
        height: 400px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border-radius: 10px;
        background-size: contain;
        background-color: #fff;
        border: 8px double #5B6BE8;
        box-shadow: 0 0 5px #5B6BE8;
    }

    .login-logo img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background-color: rgb(238, 238, 238);
    }

    .login-box {
        width: 100%;
        position: absolute;
        bottom: 0;
        padding: 0 20px;
        box-sizing: border-box;
    }

    .login-btn {
        width: 200px;

    }

    .el-input {
        width: 100%;
        margin-left: -40px;
        margin-top: 30px;
    }

    .el-button {
        width: 100px;
    }

    .box {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
    }
</style>